<!--  -->
<template>
  <div class="portal-music">
    <div class="div1">
      <div class="header-logo">
      <img
        src="https://y.gtimg.cn/mediastyle/yqq/img/logo@2x.png?nowebp=1"
        alt=""
      />
    </div>
    <div class="header-nav">
      <li >
        <a href="javascript:;" @click="getIndex">音乐馆</a>
      </li>
      <li style="background: #31c27c"><a href="javascript:;" style="color: #fff" >我的音乐</a></li>
    </div>
    <div class="header-input">
      <input type="text" placeholder="搜索音乐、MV、歌单、用户" />
      <button>
        <i></i>
      </button>
    </div>
    <div class="header-login">
      <a :class="[{ show: show }]" @click="handleLogin()">登录</a>
      <a class="showuser" :class="[{ show: !show }]"
        >{{ item }},你好!
        <p class="loginout" @click="handleLoginOut()">退出登录</p>
      </a>
    </div>
    </div>
    <div class="portal-music-header">
      <div class="portal-music-header-inner">
        <div class="portal-music-header-link">
          <span class="portal-music-header-image"></span>
        </div>
        <h1>
          <span class="portal-music-header-name">XXX</span>
          <a href="#"><img src="https://y.gtimg.cn/music/icon/v1/mac/svip_g@2x.png?max_age=2592000" alt="" class="lv"></a>
        </h1>
      </div>
    </div>
    <div class="portal-music-main">
      <div class="portal-music-main-nav">
        <a href="#" class="portal-music-main-navlike active">我喜欢</a>
        <a href="#" class="portal-music-main-navlike " @click="handleClick()">我的已购</a>
        <a href="#" class="portal-music-main-navlike " @click="handleClick1()">我创建的歌单</a>
        <a href="#" class="portal-music-main-navlike ">我上传的视频</a>
      </div>
      <div class="portal-music-main-list">
        <div class="portal-music-main-list-tab">
          <a href="#" class="portal-music-main-list-tab-item active">歌曲</a>
          <a href="#" class="portal-music-main-list-tab-item ">歌单</a>
          <a href="#" class="portal-music-main-list-tab-item ">专辑</a>
          <a href="#" class="portal-music-main-list-tab-item ">视频</a>
        </div>
        <div class="portal-music-main-list-cont">
          <div class="portal-music-main-list-cont-sub">
            <div class="portal-music-main-list-cont-sub-songlist">
              <ul class="portal-music-main-list-cont-sub-songlist-header">
                <li class="portal-music-main-list-cont-sub-songlist-header-name">歌曲</li>
                <li class="portal-music-main-list-cont-sub-songlist-header-author">歌手</li>
                <li class="portal-music-main-list-cont-sub-songlist-header-album">专辑</li>
              </ul>
              <div class="portal-music-main-list-cont-sub-songlist-list">
                <div class="div2" v-for="(item,index) in songList" :key="item.id">
                  <div class="portal-music-main-list-cont-sub-songlist-list-item">
                    <div class="portal-music-main-list-cont-sub-songlist-list-item-songname">
                      <span class="portal-music-main-list-cont-sub-songlist-list-item-songname-txt">
                        <a href="#">{{item.name}}</a>
                      </span>
                      <div class="portal-music-main-list-cont-sub-songlist-list-item-songname-menu">
                        <a href="#" class="portal-music-main-list-cont-sub-songlist-list-item-songname-menu-item">
                          <i class="portal-music-main-list-cont-sub-songlist-list-item-songname-menu-item-play" @click="handlePlay(item.id)"></i>
                        </a>
                        
                      </div>
                    </div>
                    <div class="portal-music-main-list-cont-sub-songlist-list-item-artist">
                      <a href="#">{{item.artists[0].name}}</a>
                    </div>
                    <div class="portal-music-main-list-cont-sub-songlist-list-item-album">
                      <a href="#">{{item.album.name}}</a>
                    </div>
                    <a href="#" class="portal-music-main-list-cont-sub-songlist-list-item-del" @click="handleDelete(index)"></a>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
import busline from "../busline/busline"
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      show: this.$store.state.status,
      item: localStorage.getItem("username"),
      
      // [
      //   {
      //   id:1,
      //   name:"丑八怪",
      //   artists:"薛之谦",
      //   album:"丑八怪"
      // },
      // {
      //   id:2,
      //   name:"丑八怪",
      //   artists:"薛之谦",
      //   album:"丑八怪"
      // },
      // {
      //   id:3,
      //   name:"丑八怪",
      //   artists:"薛之谦",
      //   album:"丑八怪"
      // },
      // {
      //   id:4,
      //   name:"丑八怪",
      //   artists:"薛之谦",
      //   album:"丑八怪"
      // },
      // {
      //   id:5,
      //   name:"丑八怪",
      //   artists:"薛之谦",
      //   album:"丑八怪"
      // },
      // ]
      // songs:[],
    };
  },
  //监听属性 类似于data概念
  computed: {
    // songs:function(){
    //   return this.songList
    // }
    songList:function(){
      return this.$store.state.songs2; 
    }
  },
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    handleClick:function(){
      this.$router.push("buy");
    },
    handleClick1:function(){
      this.$router.push("mycreate");
    },
    handleDelete:function(index){
      this.songList.pop(index,1);
    },
    handlePlay:function(id){
      this.$router.push("audioplayer");
      busline.$emit("sendSongurl",id)
      
    },
    getIndex(){
      this.$router.push("/")
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    // busline.$on("sendSongId",((Info)=>{
    //   // this.songList.push(Info);
    //   console.log(Info);
    //   // console.log(this.songList);
      

    // }))
  
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="less" scoped>
.portal-music {
  .div1 {
    cursor: pointer;
  width: 1200px;
  height: 90px;
  display: flex;
  margin: 0 auto;
  justify-content: space-between;
  border-bottom: 1px solid #ddd;
  .header-logo {
    margin-top: 22px;
    img {
      width: 170px;
      height: 46px;
    }
  }

  .header-nav {
    display: flex;
    margin-left: -50px;
    li {
      margin: 0 20px;
      list-style: none;
      width: 120px;
      height: 90px;
      line-height: 90px;
      text-align: center;
      font-size: 30px;
    }
    li:hover {
      a {
        color: #31c27c;
      }
    }
    a {
      list-style: none;
      color: #000;
      text-decoration: none;
    }
  }

  .header-input {
    height: 90px;
    vertical-align: auto;
    position: relative;
    line-height: 90px;
    input {
      padding: 0 10px;
      outline: none;
      width: 200px;
      height: 30px;
    }
    button {
      position: absolute;
      top: 30px;
      right: 0;
      border: 0 none;
      width: 38px;
      height: 35px;
      overflow: visible;
      background: 0 0;
    }
    i {
      background-image: url(https://y.gtimg.cn/mediastyle/yqq/img/icon_sprite.png?max_age=2592000&v=85678e8f28c7b4bcad5c209b21b7e3b3&v=85678e8f28c7b4bcad5c209b21b7e3b3);
      position: absolute;
      top: 50%;
      right: 11px;
      margin-top: -8px;
      width: 17px;
      height: 17px;
      background-position: 0 -40px;
    }
    i:hover {
      background-position: 0 -60px;
    }
  }

  .header-login {
    padding: 0 50px;
    height: 90px;
    vertical-align: auto;
    line-height: 90px;
    margin-left: -30px;
    position: relative;
    .show {
      display: none;
    }
    a {
      display: inline-block;
      height: 90px;
      color: #000;
      text-decoration: none;
      font-size: 20px;
    }
    a:hover {
      color: #31c27c;
    }
    .showuser {
      .loginout {
        position: absolute;
        background: #fff;
        height: 30px;
        width: 100%;
        color: #000;
        font-size: 16px;
        line-height: 30px;
        text-align: center;
        display: none;
        right: 0;
        top: 57px;
      }
    }
    .showuser:hover .loginout {
      display: block;
    }
  }
  }

  .portal-music-header {
    background: url(../assets/bg_profile.jpg) 50% no-repeat;
    background-size: cover;
    text-align: center;
    color: #fff;
    height: 315px;
    width: 100%;
    padding-top: 65px;
  }
  .portal-music-header-inner{
    height: 315px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
  }
  .portal-music-header-link{
    position: relative;
    width: 102px;
    height: 102px;
    margin: 0 auto;
  }
  .portal-music-header-image{
    display: block;
    width: 100%;
    height: 100%;
    border: 4px solid #fff;
    border-radius: 99px;
    background: #fff;
  }
  h1{
    font-size: 0;
  }
  .portal-music-header-name{
    font-size: 30px;
    font-weight: 400;
    line-height: 64px;
    margin-right: 14px;
  }
  a{
    text-decoration: none;
    
  }
  .lv{
    vertical-align: -3px;
  }
  .portal-music-main{
    min-height: 500px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
  }
  .portal-music-main-nav{
    position: absolute;
    top: -56px;
    left: 0;
    margin-bottom: 0;
    width: 80%;
    overflow: hidden;
    border-bottom: 0 none;
    height: 56px;
    line-height: 56px;
  }
   .portal-music-main-navlike:hover{
     color: #31c27c;
   }
   .active{
     color: #31c27c !important;
   }
  .portal-music-main-navlike{
    margin-right: 40px;
    position: relative;
    float: left;
    font-size: 16px;
    overflow: hidden;
    height: 56px;
    line-height: 56px;
    color: #fff;
  }
  .portal-music-main-list-tab{
    margin-bottom: -20px;
    overflow: hidden;
    border-bottom: 0 none;
    position: relative;
    height: 56px;
    line-height: 56px;
  }
  .portal-music-main-list-tab-item{
    position: relative;
    float: left;
    font-size: 16px;
    overflow: hidden;
    margin-right: 55px;
    height: 56px;
    line-height: 56px;
    color: black;
  }
  .portal-music-main-list-tab-item:hover{
    color: #31c27c;
  }
  .portal-music-main-list-cont-sub-songlist{
    padding-bottom: 40px;
    font-size: 14px;
    overflow: hidden;
  }
  .portal-music-main-list-cont-sub-songlist-header{
    padding-left: 20px;
    height: 50px;
    line-height: 50px;
    background-color: rgba(0,0,0,.01);
    color: #999;
    position: relative;
    padding-right: 95px;
    margin-top: 50px;
  }
  .portal-music-main-list-cont-sub-songlist-header-name{
    width: 56%;
    float: left;
    position: relative;
    white-space: normal;
    list-style: none;
  }
  .portal-music-main-list-cont-sub-songlist-header-author{
    width: 22%;
    float: left;
    padding-left: 15px;
    box-sizing: border-box;
    list-style: none;
  }
  .portal-music-main-list-cont-sub-songlist-header-album{
    width: 22%;
    float: left;
    padding-left: 15px;
    box-sizing: border-box;
    list-style: none;
  }
  .portal-music-main-list-cont-sub-songlist-list{
    min-height: 500px;
    width: 1200px;
    overflow: hidden;
    clear: both;
  }
  .div2{

  }
  .portal-music-main-list-cont-sub-songlist-list-item{
    padding-left: 20px;
    clear: both;
    font-size: 0;
    overflow: hidden;
    position: relative;
    padding-right: 95px;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-songname{
    width: 56%;
    float: left;
    position: relative;
    line-height: 50px;
    height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-songname-txt{
    max-width: 72%;
    box-sizing: border-box;
    float: left;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
    white-space: nowrap;
    font-size: 14px;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-songname-menu{
    position: absolute;
    right: -10px;
    top: 20%;
    overflow: hidden;
    opacity: 1;
    pointer-events: none;
    height: 36px;
    font-size: 0;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-songname-menu-item{
    display: inline-block;
    margin-right: 148px;
    vertical-align: top;
  }
  .div2:hover .portal-music-main-list-cont-sub-songlist-list-item-songname-menu-item-play{
    visibility: visible;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-songname-menu-item-play{
    display: block;
    width: 36px;
    height: 36px;
    background: url(../assets/icon_list_menu.png) no-repeat;
    background-position: 0 0;
    visibility: hidden;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-artist{
    width: 22%;
    float: left;
    padding-left: 15px;
    box-sizing: border-box;
    line-height: 50px;
    height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-album{
    width: 22%;
    float: left;
    padding-left: 15px;
    box-sizing: border-box;
    line-height: 50px;
    height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }
  .portal-music-main-list-cont-sub-songlist-list-item-del{
    background: url(../assets/icon_list_menu.png);
    position: absolute;
    top: 50%;
    right: 58px;
    margin-top: -18px;
    width: 36px;
    height: 36px;
    background-position: 0 -160px;
    visibility: hidden;
  }
  .div2:hover .portal-music-main-list-cont-sub-songlist-list-item-del{
    visibility: visible;
  }
}
</style>